//
//  HomeCargoInformationVC.m
//  shuiyun
//
//  Created by 马田成 on 2017/9/6.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "HomeCargoInformationVC.h"
#import "ZJScrollPageView.h"
#import "HomeCargoInformatonLongVC.h"
#import "HomeDQHYMViewController.h"
#import "HomeCatgoinTUIJIViewController.h"
#import "HomeDQHYMViewController.h"

@interface HomeCargoInformationVC ()<ZJScrollPageViewDelegate>


@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;
@property(strong, nonatomic)NSArray<NSString *> *titles;


@end

@implementation HomeCargoInformationVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    // Do any additional setup after loading the view.
}
- (void)creationView{

    [self setTitle:@"货源信息"];
    
//    UIButton *buttonAdd = [[UIButton alloc] init];
//    
//    buttonAdd.frame = CGRectMake(DEF_SCREEN_WIDTH - 40, 0, 40, 40);
//    
//    [buttonAdd setImage:[UIImage imageNamed:@"icon_sousuo"] forState:UIControlStateNormal];
//    [buttonAdd addTarget:self action:@selector(messageClick) forControlEvents:UIControlEventTouchUpInside];
//    
//    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc]initWithCustomView:buttonAdd];
//    self.navigationItem.rightBarButtonItem = rightItme;
    
    
    
    UIButton *buttonOfDQ = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH / 2, 50)];
    
    [self.view addSubview:buttonOfDQ];
    [buttonOfDQ addTarget:self action:@selector(DQclick) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageViewOfDQ = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"huoyuanxinxi_icon_diqu"]];
    [buttonOfDQ addSubview:imageViewOfDQ];
    [imageViewOfDQ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(buttonOfDQ.mas_centerY);
        make.left.equalTo(buttonOfDQ).with.offset(28);
        
    }];
    UILabel *labelOfDQ = [[UILabel alloc] init];
    [buttonOfDQ addSubview:labelOfDQ];
    labelOfDQ.text = @"地区货源";
    [labelOfDQ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(buttonOfDQ.mas_centerY);
        make.left.equalTo(imageViewOfDQ.mas_right).with.offset(10);
        make.height.offset(17);
        
        
    }];
    labelOfDQ.font = [UIFont systemFontOfSize:17];
    labelOfDQ.textColor = getColor(@"333333");
    
    UIView *viewGray = [[UIView alloc] init];
    [self.view addSubview:viewGray];
    [viewGray mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.equalTo(buttonOfDQ.mas_right);
        make.height.offset(50);
        make.width.offset(1);
        
        
    }];
    viewGray.backgroundColor = getColor(@"EEEEEE");
    
    UIButton *buttonOfTJ = [[UIButton alloc] init];
    [self.view addSubview:buttonOfTJ];
    [buttonOfTJ addTarget:self action:@selector(tuiJIanClick) forControlEvents:UIControlEventTouchUpInside];
    [buttonOfTJ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.left.equalTo(viewGray.mas_right);
        make.right.equalTo(self.view);
        make.height.offset(50);
        
        
    }];
    
    UIImageView *imageViewOfTJ = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_tuijian"]];
    [buttonOfTJ addSubview:imageViewOfTJ];
    
    [imageViewOfTJ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(buttonOfTJ.mas_centerY);
        make.left.equalTo(buttonOfTJ).with.offset(28);
        
    }];
    
    UILabel *labelOfTJ = [[UILabel alloc] init];
    [buttonOfTJ addSubview:labelOfTJ];
    labelOfTJ.text = @"推荐货源";
    [labelOfTJ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(buttonOfTJ.mas_centerY);
        make.left.equalTo(imageViewOfTJ.mas_right).with.offset(10);
        make.height.offset(17);
        
        
    }];
    labelOfTJ.font = [UIFont systemFontOfSize:17];
    labelOfTJ.textColor = getColor(@"333333");
    UIView *viewOfH = [[UIView alloc] init];
    [self.view addSubview:viewOfH];
    [viewOfH mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(buttonOfTJ.mas_bottom);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(2);
        
    }];
    viewOfH.backgroundColor = getColor(@"EEEEEE");
    
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    style.scrollTitle = YES;
    style.autoAdjustTitlesWidth = YES;
    style.adjustCoverOrLineWidth = YES;
    style.selectedTitleColor = [UIColor colorWithRed:63 / 255.0f green:135 / 255.0f blue:246 / 255.0f alpha:1];
    style.scrollLineColor = [UIColor colorWithRed:63 / 255.0f green:135 / 255.0f blue:246 / 255.0f alpha:1];
    style.segmentHeight = 40;
    self.titles = @[@"长期货源",
                    @"热门货源",
                    ];
    
    // 初始化
    ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 52, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [scrollPageView setSelectedIndex:self.indexID animated:YES];
    scrollPageView.contentView.scrollView.scrollEnabled = YES;
    [self.view addSubview:scrollPageView];

    
    
}

#pragma mark ----------------ZJScrollPageViewDelegate---------------------
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}
- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    HomeCargoInformatonLongVC <ZJScrollPageViewChildVcDelegate> *childVc = (HomeCargoInformatonLongVC *)reuseViewController;
    
    if (!childVc) {
        
        childVc = [[HomeCargoInformatonLongVC alloc] init];
        
        childVc.orderStatus = index;
        
        //        childVc.orderStatus = [self.arrOfName objectAtIndex:index];
        
        
        NSLog(@"AAAAAAAAAAAAAAA%ld", (long)childVc.orderStatus);
        
        
    }
    
    return childVc;
}

// 地区
- (void)DQclick{

    HomeDQHYMViewController *vc = [[HomeDQHYMViewController alloc] init];

    [self.navigationController pushViewController:vc animated:YES];
    
    
}
//推荐
- (void)tuiJIanClick{

    HomeCatgoinTUIJIViewController *vc = [[HomeCatgoinTUIJIViewController alloc] init];
    [self.navigationController pushViewController: vc animated:YES];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
